﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace PathNodeGraphicEditor
{
    public class Map
    {
        [XmlAttribute("file")]
        public string file;
        [XmlAttribute("width")]
        public int width;
        [XmlAttribute("height")]
        public int height;

        public Map()
        {
            file = null;
            width = 0;
            height = 0;
        }
    }
    public class NodeInfo
    {
        [XmlAttribute("numNodes")]
        public int numNodes { get { return NodeList.Count; } set{} }
        
        [XmlElement("Node")]
        public List<Node> NodeList;

        [XmlElement("Edge")]
        public List<Edge> EdgeList;
        
        public NodeInfo()
        {
            NodeList = new List<Node>();
            EdgeList = new List<Edge>();
        }

        public uint GetStartID(int index)
        {
            return EdgeList[index].startID;
        }

        public void SetStartID(int index, uint startID)
        {
            EdgeList[index].startID = startID;
        }

        public uint GetEndID(int index)
        {
            return EdgeList[index].endID;
        }

        public void SetEndID(int index, uint endID)
        {
            EdgeList[index].endID = endID;
        }

        public uint GetX(int index)
        {
            return NodeList[index].x;
        }

        public void SetX(int index, uint x)
        {
            NodeList[index].x = x;
        }

        public uint GetY(int index)
        {
            return NodeList[index].y;
        }

        public void SetY(int index, uint y)
        {
            NodeList[index].y = y;
        }

        public uint GetID(int index)
        {
            return NodeList[index].id;
        }

        public void AddNode(uint id, uint x, uint y)
        {
            NodeList.Add(new Node(id, x, y));
        }

        public Node GetNodeAt(int index)
        {
            return NodeList[index];
        }
    }
    public class PathfindingInfo
    {
        [XmlElement("Map")]
        public Map map;
        [XmlElement("NodeInfo")]
        public NodeInfo nodeInfo;

        public PathfindingInfo()
        {
            map = new Map();
            nodeInfo = new NodeInfo();
        }

        
    }
}
